import request from '@/utils/request'

// 查询所有角色
const getRoleListAPI = () => {
  return request({
    url: 'park/sys/role'
  })
}

// 获取树型功能权限
const getTreeListAPI = () => {
  return request({
    url: 'park/sys/permision/all/tree'
  })
}

/**
 * 获取当前角色权限点列表
 * @returns
 */
const getRoleDetailAPI = roleId => {
  return request({
    url: `park/sys/role/${roleId}`
  })
}
/**
 * 获取角色成员列表
 * @returns
 */
const getRoleUserAPI = roleId => {
  return request({
    url: `park/sys/roleUser/${roleId}`
  })
}

/**
 * 添加角色
 */

const createRoleUserAPI = data => {
  return request({
    url: 'park/sys/role',
    method: 'post',
    data
  })
}

/**
 * 修改角色
 */

const updateRoleUserAPI = data => {
  return request({
    url: 'park/sys/role',
    method: 'put',
    data
  })
}

// 删除角色
const delRoleUserAPI = roleId => {
  return request({
    url: `park/sys/role/${roleId}`,
    method: 'delete'
  })
}

export {
  getRoleListAPI,
  getTreeListAPI,
  getRoleDetailAPI,
  getRoleUserAPI,
  createRoleUserAPI,
  updateRoleUserAPI,
  delRoleUserAPI
}
